#include "netbufferedevent.h"
#include <string.h>

NetBufferedEvent::NetBufferedEvent(Type type) :
    NetEvent(type),
    m_current(0)
{
    memset(m_data, 0, NET_BUFFER_DEFAULT_SIZE);
}

NetBufferedEvent::~NetBufferedEvent()
{

}

char *NetBufferedEvent::data()
{
    return m_data;
}

size_t NetBufferedEvent::length()
{
    return NET_BUFFER_DEFAULT_SIZE;
}

size_t NetBufferedEvent::dataLength()
{
    return m_current;
}

void NetBufferedEvent::setData(const char *data, size_t size)
{
    if(!data || !size){
        return;
    }

    memset(m_data, 0, NET_BUFFER_DEFAULT_SIZE);

    m_current = size < NET_BUFFER_DEFAULT_SIZE ? size : NET_BUFFER_DEFAULT_SIZE;
    memcpy(m_data, data, m_current);
}


